// 导入 request.js 工具
import request from "@/utils/request";

//评论列表分页查询
export const commentListService = (params) => {
  return request.get('/comment/findPageAll',{params:params});//两个params ，前面的是固定的，后面是自己传的参数
};
//评论添加提交
export const commentAddService = (commentData) => {
  return  request.post('/comment/add',commentData);//直接将数据以json的格式传输进去 
};

//评论修改提交
export const commentUpdateService = (commentData) => {
  return  request.put('/comment/update',commentData);
};
//删除评论
export const commentDeleteService = (id) => {
  return  request.delete('/comment/delete?id='+id);
};
//批量删除评论
export const commentBatchDeleteService = (multipleSelection) => {
  return request.put('/comment/batchDelete', multipleSelection );
};
export const expCommentServer =()=>{
  return request({
    url: "/comment/export",
    method: 'get',
    responseType: 'blob' // 设置响应类型为blob
  });
}
export const CommentUploadService= (file) => {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: "/comment/upload",
    method: 'post',
    data: formData, // 使用 data 而不是 formData
    headers: {
      'Content-Type': undefined // 让 axios 自动设置 Content-Type
    }
  });
};

export const CommentFindByCSID = (courseId) => {
  return request({
    url: "/comment//findByCourseId",
    method: 'get',
    params: { courseId }
  });
}